﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.Web;
using System.Web.Mvc;
using ORM.Common.DataAnnotations;
using ORM.Resources;

namespace ORM.Business.Models.Entities
{
	public class Guide
	{
        public int Id { get; set; }

        [Required(ErrorMessageResourceType = typeof(ValidationMessages),
                   ErrorMessageResourceName = "TitleRequired")]
        [StringLengthExtended(100, MinimumLength = 10)]
        [Display(Name = "Guide_Title", ResourceType = typeof(Labels))]
        public string Title { get; set; }
        [Required(ErrorMessageResourceType = typeof(ValidationMessages),
                   ErrorMessageResourceName = "TitleSearchRequired")]
        [StringLengthExtended(500, MinimumLength = 200)]
        [Display(Name = "Guide_ShortDescription", ResourceType = typeof(Labels))]
        public string TitleSearch { get; set; }

        [StringLengthExtended(100)]
        public string TitleUrl { get; set; }

        [StringLengthExtended(1000)]
        [Display(Name = "Guide_Image", ResourceType = typeof(Labels))]
        public string ImageUrl { get; set; }

       
        public string ContentText { get; set; }
        [StringLengthExtended(int.MaxValue / 2)] 
        [Required(ErrorMessageResourceType = typeof(ValidationMessages),
                   ErrorMessageResourceName = "GuideContentRequired")]
        [AllowHtml]
        public string ContentHtml { get; set; }

        public int Views { get; set; }
        public int Comments { get; set; }
        public int Reports { get; set; }
        [Column("PostedBy")]
        public int PostedBy { get; set; }
        public DateTime PostedDate { get; set; }

        [Column("UpdatedBy")]
        public int? UpdatedBy { get; set; }
        public DateTime? LastUpdate { get; set; }
     
        public bool IsDeleted { get; set; }
        public bool isApproved { get; set; }
        public int RateTimes { get; set; }
        public int TotalRates { get; set; }

        [Display(Name = "Question_ModelId", ResourceType = typeof(Labels))]
        [Required(ErrorMessageResourceType = typeof(ValidationMessages),
                  ErrorMessageResourceName = "ModelIdRequired")]
        public int ModelID { get; set; }
        [Required(ErrorMessageResourceType = typeof(ValidationMessages),
                  ErrorMessageResourceName = "GuideTypeRequired")]
        public int GuideTypeId { get; set; }
        public int? Point { get; set; }
        public int? UpVotes { get; set; }
        public int? DownVotes { get; set; }
        
        //[RequiredExtended]
        //[Column("MappingCategories")]
        //[Display(Name = "Guide_MappingCategories", ResourceType = typeof(Labels))]
          public int? MappingCategories { get; set; }

          [NotMapped]
          public virtual bool IsVotedByCurrentUser { get; set; }
          [NotMapped]
          public virtual bool IsReportedByCurrentUser { get; set; }
          [NotMapped]
          public virtual bool IsAddedBookmarkByCurrentUser { get; set; }
        
        [ForeignKey("PostedBy")]   //hungnm
        public virtual user PostedByUser { get; set; } 
          

        [ForeignKey("ModelID")]
        public virtual Model Model { get; set; }

        [ForeignKey("GuideTypeId")]
        public virtual GuideType GuideType { get; set; }

        [InverseProperty("Guide")]
        public virtual ICollection<GuideComment> GuideComments { get; set; }

        //[ForeignKey("UpdatedBy")]
        //public virtual user UpdatedBy { get; set; }

        /*
       [ForeignKey("MappingCategoryId")]
       public virtual RecipeCategoryMapping MappingCategories { get; set; }*/

	}
}